package cn.hy.config;

import cn.hy.entity.Order;
import cn.hy.enums.OrderStatusEnum;
import cn.hy.events.OrderStatusChangeEvent;
import cn.hy.machine.OrderStatusMachinePersist;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.statemachine.persist.DefaultStateMachinePersister;
import org.springframework.statemachine.persist.StateMachinePersister;

import javax.annotation.Resource;


@Configuration
public class OrderStatusMachinePersistConfig {

    @Resource
    private OrderStatusMachinePersist orderStatusMachinePersist;

    @Bean(name="orderStatusMachinePersister")
    public StateMachinePersister<OrderStatusEnum, OrderStatusChangeEvent, Order> orderPersist() {
        return new DefaultStateMachinePersister<>(orderStatusMachinePersist);
    }

}
